#include "ComputeOperationNode.h"
#include "ExpressionNode.h"
#include "Column.h"

ComputeOperationNode::ComputeOperationNode(OperationNode* source, SharedArray<ExpressionNode*> expressionRoots):
		_source(source),
		_expressionRoots(expressionRoots) {}

ComputeOperationNode::~ComputeOperationNode() {
	delete _source;
	for (int i = 0; i < _expressionRoots.size(); ++i)
		delete _expressionRoots[i];
}

SharedArray<Column> ComputeOperationNode::pull() {
	SharedArray<Column> in = _source->pull();
	SharedArray<Column> out(_expressionRoots.size());
	
	for (int i = 0; i < _expressionRoots.size(); ++i) {
		out[i] = _expressionRoots[i]->pull(in);
	}

	return out;
}
